package com.yunwaikeji.gy_tool_library.mvvm.view.activity

import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import com.yunwaikeji.gy_tool_library.mvvm.viewmodel.GYViewModel
import com.yunwaikeji.gy_tool_library.utils.GYClassUtils

abstract class GYApiActivity<ViewModel : GYViewModel> : GYActivity() {
    val mViewModel: ViewModel by lazy {
        ViewModelProvider(this).get(GYClassUtils.getGenericSuperclass(this,1))
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mViewAdmin.addDataObserver(mViewModel)
    }

    fun getMViewModel1(): ViewModel {
        return mViewModel
    }
}